package cn.sjtu.algorithm.prefix_sum;

import java.util.Scanner;

/**
 * @author syo 2319615164@qq.com
 * @description 一维前缀和 模板题
 * @date 2024/5/16
 * @Copyright syo
 */
public class AcWing754 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[] prefixSum = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            prefixSum[i] = prefixSum[i - 1] + in.nextInt();
        }

        for (int i = 0; i < m; i++) {
            int l = in.nextInt();
            int r = in.nextInt();
            System.out.println(prefixSum[r] - prefixSum[l - 1]);
        }
    }
}
